//
//  AppDelegate.swift
//  SHWeibo2.0
//
//  Created by 黄礼潮 on 16/2/21.
//  Copyright © 2016年 黄礼潮. All rights reserved.
//

import UIKit
import AFNetworking

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
        print(UserAccount.shardUserAccount)
        
        setAFNetworking()
      
        setupColor()
        
        window = UIWindow(frame: UIScreen.mainScreen().bounds)
        window?.backgroundColor = UIColor.whiteColor()
        window?.rootViewController = MainViewController()
        window?.makeKeyAndVisible()
        
        
        return true
    }

}

extension AppDelegate{
    //设置全局外观颜色，一经设置全局有效
    private  func setupColor(){
        
        UINavigationBar.appearance().tintColor = CZColor
        UITabBar.appearance().tintColor = CZColor
        UINavigationBar.appearance().titleTextAttributes = [NSFontAttributeName:UIFont.systemFontOfSize(16)]
    }
    
    private func  setAFNetworking(){
    
        //下载网络指示器   如果在使用SDWebImage 下载图片的时候，是不会显示的
        AFNetworkActivityIndicatorManager.sharedManager().enabled = true
       //AFN 默认用的是苹果原装的框架的内存设置
        // memoryCapacity 内存大小 diskCapacity 磁盘的大小
        NSURLCache.setSharedURLCache(NSURLCache(memoryCapacity: 4 * 1024 * 1024, diskCapacity: 20 * 1024 * 1024, diskPath: nil))
    
    }
    
    
}


